package com.example.yichuangyun.mvvm.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.DataBindingHolder;
import com.example.yichuangyun.R;
import com.example.yichuangyun.databinding.ItemInvoiceBinding;
import com.example.yichuangyun.model.order.InvoiceDataModel;
import com.example.yichuangyun.utils.CommonUtil;
import com.example.yichuangyun.utils.UiUtils;

public class InvoiceAdapter extends BaseQuickAdapter<InvoiceDataModel.InvoiceModel, DataBindingHolder<ItemInvoiceBinding>> {
    @Override
    protected void onBindViewHolder(@NonNull DataBindingHolder<ItemInvoiceBinding> itemFileInfoBindingDataBindingHolder, int i, @Nullable InvoiceDataModel.InvoiceModel invoiceModel) {
        ItemInvoiceBinding binding = itemFileInfoBindingDataBindingHolder.getBinding();
        binding.setInvoiceModel(invoiceModel);
        if (invoiceModel != null) {
            if (invoiceModel.getType() == 1) {
                binding.tvInvoiceStatus.setText(CommonUtil.setText(invoiceModel.getAuditResult()));
            } else {
                binding.tvInvoiceStatus.setText(UiUtils.getInvoiceStatus(invoiceModel.getType()));
            }
        }
    }

    @NonNull
    @Override
    protected DataBindingHolder<ItemInvoiceBinding> onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new DataBindingHolder<>(R.layout.item_invoice, viewGroup);
    }
}
